package com.no1.musicmgr.service;

import com.no1.musicmgr.mapper.MusicAnalysisMapper;
import com.no1.musicmgr.mapper.UserAnalysisMapper;
import com.no1.musicmgr.vo.MusicVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author 17739
 */
@Log4j
@Service
public class MusicAnalysisService {
    @Autowired
    private MusicAnalysisMapper musicAnalysisMapper;

    public HashMap<String, Object> getUserAnalysisData() {
        HashMap<String, Object> map = new HashMap<>();
        // 音乐类别
        map.put("music_type", musicAnalysisMapper.getMusicDataByType());
        // 音乐热门状态
        map.put("music_rm", musicAnalysisMapper.getMusicDataByRm());
        // 音乐总数量
        map.put("totalMusicCount", musicAnalysisMapper.getTotalMusicCount());
        // 音乐热门总数
        map.put("totalMusicRm", musicAnalysisMapper.getTotalMusicRm());
        // 音乐免费数量
        map.put("musicFreeCount", musicAnalysisMapper.getMusicFreeCount());
        // 今年音乐总发布数
        map.put("releaseThisYear", musicAnalysisMapper.getReleaseThisYear());
        // 去年音乐发布数
        map.put("releaseLastYear", musicAnalysisMapper.getReleaseLastYear());
        // 网站热度
        MusicVo musicVo = new MusicVo();
        musicVo.setTotalTuCount(musicAnalysisMapper.getTotalTu());
        musicVo.setTotalScCount(musicAnalysisMapper.getTotalSc());
        musicVo.setWebMusicHeat(musicVo.getTotalTuCount() + musicVo.getTotalScCount() * 3);
        map.put("webMusicHeat", musicVo);
        return map;
    }
}
